package cn.bytecollege.user.controller;

import cn.bytecollege.common.entity.Address;
import cn.bytecollege.user.service.AddressService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(name = "AddressUpdateController",value = "/user/addressUpdate")
public class AddressUpdateController extends HttpServlet {
    AddressService addressService=null;
    public AddressUpdateController(){
        addressService=new AddressService();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AddressService addressService=new AddressService();
        Address address=new Address();
        //1.封装数据
        String addressConsignee=request.getParameter("Consignee");
        String addressPhonenumber=request.getParameter("Phonenumber");
        String addressProvince=request.getParameter("province");
        String addressCity=request.getParameter("city");
        String addressCounty=request.getParameter("county");
        String addressProfile=request.getParameter("Profile");
        String addressId=request.getParameter("addressId");

        address.setAddressConsignee(addressConsignee);
        address.setAddressProvince(addressProvince);
        address.setAddressPhonenumber(addressPhonenumber);
        address.setAddressCity(addressCity);
        address.setAddressCounty(addressCounty);
        address.setAddressProfile(addressProfile);
        address.setAddressId(Integer.valueOf(addressId));
        addressService.update(address);
        response.sendRedirect("/addAddress");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
